﻿<h3>Реализация паттерна Iterator</h3>
<p>Дополните ваш класс-обертку http-запроса реализацией интерфейса итератора и проверьте его работу  с помощью оператора foreach</p>
<hr/>
<?php const BR = PHP_EOL; ?>
<?php if($model->HttpMethod == "POST"): ?>

<fieldset>
  <legend>POST запрос</legend>
<pre><?php

foreach ($model as $name => $value):

  echo " - {$name} = {$value}" . BR;

  if (is_array($value))
    foreach ($value as $key => $val)
      echo " - {$name}[{$key}] = {$val}" . BR;

endforeach;


if ($model->HttpMethod == "POST"):

  echo BR . "POST [Form]: " . BR;


  foreach ($model->Form('Form') as $name => $value)
    echo " - {$name}[{$name}] = {$value}" . BR;


  echo BR . "MODEL: ";

  $form = $model->Form()->ToObject(Form);
  $form->files = $model->Files('Form')->ToArray();
  print_r($form);

endif;
?></pre>
</fieldset>

<?php endif; ?>

<fieldset>
  <legend>Тестовая форма</legend>
  <hr/>
  <form method="POST" action="<?= My::Mvc()->UrlManager->Resolve('my', 'request'); ?>"
        enctype="multipart/form-data">
    <input name="Security" type="hidden" value="security value" />
    <input name="Form[hidden]" type="hidden" value="hidden value"   />

    <label>Select</label>
    <select name="Form[select]">
      <option value="">All</option>
      <option value="0">Option 1</option>
      <option value="1">Option 1</option>
      <option value="2">Option 1</option>
    </select>

    <label>Text</label>
    <input name="Form[text]" type="text" value="text value"   />

    <label>Checkbox</label>
    <input name="Form[checkbox]" type="checkbox" value="1" />

    <label>Radio</label>
    <input name="Form[radio]" type="radio" value="1" />
    <input name="Form[radio]" type="radio" value="2" />
    <input name="Form[radio]" type="radio" value="3" />

    <label>File</label>
    <input name="Form[file]" type="file" />

    <hr/>
    <input type="submit" />
  </form>
</fieldset>
